#include <stdio.h>
#include <stddef.h>

#define container_of(ptr, type, member) ({ \
                        (type *)((char*)ptr - offsetof(type, member));})

struct to_parent
{
    int i;
    int j;
    int k;
};

int main(int argc, char *argv[])
{
    struct to_parent s = 
    {
        .i = 1,
        .j = 2,
        .k = 3
    };

    struct to_parent *test;

    test = container_of(&s.j, struct to_parent, j);

    printf("s.i = %d.\n", test->i);

    return 0;
}
